#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//

void solve()
{
	int x1,y1,x2,y2,x3,y3;
	cin>>x1>>y1>>x2>>y2>>x3>>y3;
	if(y1==y2&&y3<y2) cout<<abs(x2-x1)<<'\n';
	else if(y2==y3&&y1<y2) cout<<abs(x3-x2)<<'\n';
	else if(y1==y3&&y2<y1) cout<<abs(x3-x1)<<'\n';
	else cout<<0<<'\n';


	
}

int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}